package me.leon.ade

import android.content.Context
import android.content.Intent
import android.util.Log
import io.github.leon406.ext.onClick
import io.github.leon406.ext.onDebounceClick
import java.util.*
import me.leon.ade.databinding.ActivityToExtraBinding
import me.leon.ext.android.*

class ToExtraActivity : AbsBindingActivity<ActivityToExtraBinding>() {
    private val name: String? by extra("", "name2")
    private val age: Int? by extra(0)
    private val stringList: ArrayList<String> by extra(arrayListOf())
    private val stringArray: Array<String> by extraArray(key = "stringArray1")

    override fun ActivityToExtraBinding.init() {
        Log.d("App__", "$name $age $stringList ${stringArray.contentToString()}")

        Log.d(
            "BarUtils",
            "${BarUtils.actionBarHeight} ${BarUtils.statusBarHeight}  ${BarUtils.navBarHeight}"
        )
        Log.d(
            "BarUtils",
            "${Integer.toHexString(BarUtils.getNavBarColor(window))} ${
                BarUtils.isStatusBarLightMode(this@ToExtraActivity)
            } "
        )

        tv.setOnClickListener {
            //            BarUtils.setStatusBarColor(this,colorRes(R.color.colorPrimary),true)
            BarUtils.setStatusBarLightMode(
                this@ToExtraActivity,
                !BarUtils.isStatusBarLightMode(this@ToExtraActivity)
            )
            BarUtils.setStatusBarVisibility(
                this@ToExtraActivity,
                !BarUtils.isStatusBarVisible(this@ToExtraActivity)
            )
        }

        rb1.onClick(2000) { println("throttle 111111") }

        rb2.onDebounceClick { println("dd 1d11111") }
    }
    companion object {
        fun start(context: Context) {
            context.startActivity(
                Intent(context, ToExtraActivity::class.java).apply {
                    addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                }
            )
        }
    }
}
